package com.sunwayworld.basemodule.coredata.pjproduct.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.coredata.pjproduct.dao.LimsPurposeMethodDao;
import com.sunwayworld.basemodule.coredata.pjproduct.bean.LimsPurposeMethodBean;
import com.sunwayworld.basemodule.coredata.pjproduct.service.LimsPurposeMethodService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsPurposeMethodServiceImpl implements LimsPurposeMethodService {

    @Autowired
    private LimsPurposeMethodDao limsPurposeMethodDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsPurposeMethodDao getDao() {
        return limsPurposeMethodDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsPurposeMethodBean limsPurposeMethod = jsonWrapper.parseUnique(LimsPurposeMethodBean.class);
        limsPurposeMethod.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsPurposeMethod);
        return limsPurposeMethod.getId();
    }

}
